package com.qf.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.mapper.BusinessMapper;
import com.qf.model.Business;
import com.qf.service.BusinessService;
import com.qf.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class BusinessServiceImpl implements BusinessService {
    @Autowired
    private BusinessMapper businessMapper;
    @Override
    public ResultData findAll(HashMap<String, Object> map) {
        String pageNo = (String) map.get("page");
        String pageSize = (String) map.get("limit");
        PageHelper.startPage(Integer.parseInt(pageNo),Integer.parseInt(pageSize));
        // 查询全部
        List<Business> list = businessMapper.findAll(map);
        PageInfo<Business> info = new PageInfo<>(list);
        // 计数
        return ResultData.ok( list, (int) info.getTotal());
    }
}
